home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-12-08 | 45.9 KB | 1,156 lines | [TEXT/R*ch] |
- C.S.M.P. Digest Wed, 11 Nov 92 Volume 1 : Issue 212
-
- Today's Topics:
-
- Regular Expressions
- Another Sound Manager Question (recording on PB)
- Deferred Tasks - What can I do?
- problem with my dialog filter
- Apple Events! How to locate a service?
-
-
-
- The Comp.Sys.Mac.Programmer Digest is moderated by Michael A. Kelly.
-
- The digest is a collection of article threads from the internet newsgroup
- comp.sys.mac.programmer. It is designed for people who read c.s.m.p. semi-
- regularly and want an archive of the discussions. If you don't know what a
- newsgroup is, you probably don't have access to it. Ask your systems
- administrator(s) for details. (This means you can't post questions to the
- digest.)
-
- Each issue of the digest contains one or more sets of articles (called
- threads), with each set corresponding to a 'discussion' of a particular
- subject. The articles are not edited; all articles included in this digest
- are in their original posted form (as received by our news server at
- cs.uoregon.edu). Article threads are not added to the digest until the last
- article added to the thread is at least one month old (this is to ensure that
- the thread is dead before adding it to the digest). Article threads that
- consist of only one message are generally not included in the digest.
-
- The entire digest is available for anonymous ftp from ftp.cs.uoregon.edu
- [128.223.8.8] in the directory /pub/mac/csmp-digest. Be sure to read the
- file /pub/mac/csmp-digest/README before downloading any files. The most
- recent issues are available from sumex-aim.stanford.edu [36.44.0.6] in the
- directory /info-mac/digest/csmp. If you don't have ftp capability, the sumex
- archive has a mail server; send a message with the text '$MACarch help' (no
- quotes) to LISTSERV@ricevm1.rice.edu for more information.
-
- The digest is also available via email. Just send a note saying that you
- want to be on the digest mailing list to mkelly@cs.uoregon.edu, and you will
- automatically receive each new issue as it is created. Sorry, back issues
- are not available through the mailing list.
-
- Send administrative mail to mkelly@cs.uoregon.edu.
-
-
- -------------------------------------------------------
-
- From: rpd@hera.Sbi.Com (Richard P. Daley)
- Subject: Regular Expressions
- Date: 30 Sep 92 23:19:11 GMT
- Organization: Fulcrum - Salomon Brothers, NY
-
- Does anyone know where I can find source code to implement searching through
- text for regular expressions? I'm hoping to find something like re_comp()
- and re_exec() on the Sun.
-
- +++++++++++++++++++++++++++
-
- From: spencer@panix.com (David Spencer)
- Date: Thu, 1 Oct 1992 18:03:58 GMT
- Organization: PANIX Public Access Unix, NYC
-
- In <1520@twinkletoes.hera.Sbi.Com> rpd@hera.Sbi.Com (Richard P. Daley) writes:
-
- >Does anyone know where I can find source code to implement searching through
- >text for regular expressions? I'm hoping to find something like re_comp()
- >and re_exec() on the Sun.
-
- The gnu regular expression library is at prep.ai.mit. The version in
- the grep/egrep sources has been built and tested (for years) by
- wizards. The separate regex library is called beta, but it's an
- extended and rationalized version of the grep regex code.
-
- It has bsd compatible calls, as well as its own comp/exec format.
-
- The bsd regex code is on gatekeeper.dec.com.
-
- You can also try the agrep code. It allows slightly more general
- searching than extended regular expressions. It's from University of
- Arizona; try archie to get the location.
-
- dhs spencer@panix.com
-
-
- +++++++++++++++++++++++++++
-
- From: merlyn@ora.com (Randal L. Schwartz)
- Date: 2 Oct 92 06:36:59 GMT
- Organization: Stonehenge Consulting Services; Portland, Oregon, USA
-
- In article <1992Oct1.180358.3460@panix.com> spencer@panix.com (David Spencer) writes:
- The gnu regular expression library is at prep.ai.mit. The version in
- the grep/egrep sources has been built and tested (for years) by
- wizards. The separate regex library is called beta, but it's an
- extended and rationalized version of the grep regex code.
-
- Remember of course that this code is subject to the GNU Public
- License. And because of RMS's opinions about Apple, you can bet that
- code for a Mac that uses these routines but violates the GPL would be
- prosecuted swiftly and painfully.
-
-
- - --
- Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
- merlyn@reed.edu (guest account) merlyn@ora.com (better for permanent record)
- cute quote: "Welcome to Portland, Oregon -- home of the California Raisins!"
-
- +++++++++++++++++++++++++++
-
- From: Reid Ellis <rae@Alias.com>
- Organization: Alias Research, Inc., Toronto ON Canada
- Date: Fri, 9 Oct 1992 19:11:33 GMT
-
- David Spencer <spencer@panix.com> writes:
- |The gnu regular expression library is at prep.ai.mit. ... The separate
- |regex library is called beta, but it's an extended and rationalized
- |version of the grep regex code.
-
- Randal L. Schwartz <merlyn@ora.com> writes:
- |Remember of course that this code is subject to the GNU Public
- |License. And because of RMS's opinions about Apple, you can bet that
- |code for a Mac that uses these routines but violates the GPL would be
- |prosecuted swiftly and painfully.
-
- Um, simply using GNU[*] code on a Mac does NOT violate the GPL. The
- political position that GNU has taken is just that -- a political
- position. There is nothing in the GPL that forbids GNU code to be
- used for Macintosh products. Period. RMS[**] and GNU do, however, ask
- that you boycott Apple's products [even to the point of developing any
- code for them] because of Apple's coporate behaviour vis-a-vis look
- and feel lawsuits.
-
- So David, feel free to use and recommend the GNU regexp library to
- Macintosh programmers if you don't agree with the position that has
- been taken by RMS and GNU.
-
- Reid
-
- [*] GNU = Gnu's Not Unix
- [**] RMS = Richard M. Stallman [sp?]
- - --
- Reid Ellis
- rae@utcs.utoronto.ca || rae@Alias.com
- CDA0610@applelink.apple.com || +1 416 362 9181 [work]
-
- +++++++++++++++++++++++++++
-
- From: dougm@cns.caltech.edu (Doug McNaught)
- Date: 9 Oct 92 21:48:55
- Organization: California Institute of Technology
-
- In article <1992Oct9.191133.16952@alias.com> Reid Ellis <rae@Alias.com> writes:
-
- David Spencer <spencer@panix.com> writes:
- |The gnu regular expression library is at prep.ai.mit. ... The separate
- |regex library is called beta, but it's an extended and rationalized
- |version of the grep regex code.
-
- Randal L. Schwartz <merlyn@ora.com> writes:
- |Remember of course that this code is subject to the GNU Public
- |License. And because of RMS's opinions about Apple, you can bet that
- |code for a Mac that uses these routines but violates the GPL would be
- |prosecuted swiftly and painfully.
-
- Um, simply using GNU[*] code on a Mac does NOT violate the GPL. The
- political position that GNU has taken is just that -- a political
- position. There is nothing in the GPL that forbids GNU code to be
- used for Macintosh products. Period. RMS[**] and GNU do, however, ask
- that you boycott Apple's products [even to the point of developing any
- code for them] because of Apple's coporate behaviour vis-a-vis look
- and feel lawsuits.
-
- Using GNU code on a Mac doesn't in itself violate the GPL, correct.
- Randal's point is that code that does violate the GPL (as in, you
- release the binary but refuse to make the source freely available)
- would probably be more likely to attract a suit due to the FSF's
- position.
-
- So David, feel free to use and recommend the GNU regexp library to
- Macintosh programmers if you don't agree with the position that has
- been taken by RMS and GNU.
-
- As long as source is freely available, there is no violation.
- - -doug
- - --
- Doug McNaught |"Sadder still to watch it die/ Then never to have
- dougm@cns.caltech.edu | known it/ For you, the blind who once could see/
- doug@midget.towson.edu | The bell tolls for thee..." --Neil Peart
- Nobody approves my opinions! Not even me, sometimes. Read at your own risk.
-
- ---------------------------
-
- From: olson@groucho.wi.edu (Eric K. Olson)
- Subject: Another Sound Manager Question (recording on PB)
- Organization: Whitehead Institute for Biomedical Research
- Date: Tue, 6 Oct 1992 18:04:58 GMT
-
- I've been trying to get SPBRecordToFile() to do its thing for me,
- on a PowerBook 170, running 7.0.1 + TuneUp 1.1.1, without too much
- luck. Here's what I'm doing (schematically):
-
- - Opening a data file (fsRdWrPerm).
- - Opening the default sound device with siWritePermission.
- - Getting the sample rate, sample size, number of channels,
- and compression type from SPBGetDeviceInfo().
- - Calling SetupAIFFHeader with the information received from
- SPBGetDeviceInfo(), the file refnum, and a buffer
- length (which is fixed at 64K).
- - Calling SPBRecordToFile() with the file refnum, a SPB, and
- the async flag set to FALSE. The SPB has only
- the inRefNum and the count fields set to non-zero
- values (and the count field is set to 64K).
- - Closing the data file.
- - Closing the sound device.
-
- I've looked at the info returned from SPBGetDeviceInfo(): it is all
- very normal, 8 bits/sample, 'NONE' compression, one channel.
-
- When I play back with SndStartFilePlay() I hear that the file
- has the sound in it, but with a LOT of very gravelly noise on top of it.
-
- Other things I've tried that work:
-
- - Playing sound files recorded with SndRecordToFile() with
- the _same_ playback routine as above
- - Recording and playing in memory using SPBSetupSndHeader()
-
- I tried opening a sound channel before recording (not that it should
- matter), but that didn't change anything. I think that the playback
- routine is OK, since it works with files recorded via
- SndRecordToFile() (the routine that displays the recording dialog). I
- looked at the AIFF file and it seems to be in the correct format. I
- suspect that the actual samples being recorded are corrupted somehow
- before being written to the disk. Why does SndRecordToFile() work
- when my routine fails? Is the PowerBook actually unable to record
- directly to disk (and is SndRecordToFile() not going directly to
- disk, but faking it by going to memory first)?
-
- I also noticed that the 'qual' and 'chac' selectors don't work in
- SPBGetDeviceInfo(). Strange....
-
- Any Ideas?
-
- Thanks!
-
- - -Eric
-
-
- - --
- Eric K. Olson
- Whitehead Institute for Biomedical Research
- 9 Cambridge Center, Cambridge, MA 02142
- olson@genome.wi.edu (617) 258-5572
-
- +++++++++++++++++++++++++++
-
- From: olson@genome.wi.edu (Eric K. Olson)
- Date: 8 Oct 92 17:19:59 GMT
- Organization: Whitehead Institute for Biomedical Research
-
- In article <1992Oct6.180458.15224@genome.wi.edu> I (Eric K. Olson) write:
- >I've been trying to get SPBRecordToFile() to do its thing for me,
- >on a PowerBook 170, running 7.0.1 + TuneUp 1.1.1, without too much
- >luck. Here's what I'm doing (schematically):
- > [...]
- >When I play back with SndStartFilePlay() I hear that the file
- >has the sound in it, but with a LOT of very gravelly noise on top of it.
-
- Well, I found the answer to this question after a lot of trial and error.
- It turns out that AIFF files expect the sound data to be in two's-complement
- format, so one has to turn that on (SetDeviceInfo('twos'...)) in order
- to record directly to an AIFF file. The gravelly noise is a result of
- the sign bit being interpreted as a place value of 128.
-
- Also, although the 'qual' selector doesn't work with GetDeviceInfo(),
- it does work with SetDeviceInfo(). You can set it to 'good' ('MAC6' compression),
- 'betr' ('MAC3' compression), or 'best' ('NONE' compression). Setting the
- compression directly seems to always return an error.
-
- Still don't know why the 'chac' selector fails.
-
- So it would seem that you are supposed to set the 'qual' first, then
- muck with other settings later.
-
- NEW QUESTION: Can I use 11 kHz (or lower) sampling rate with 'good'
- 'qual' ('MAC6' compression)?
-
- Anybody else playing with this?
-
- - -Eric
-
-
- - --
- Eric K. Olson
- Whitehead Institute for Biomedical Research
- 9 Cambridge Center, Cambridge, MA 02142
- olson@genome.wi.edu (617) 258-5572
-
- +++++++++++++++++++++++++++
-
- From: REEKES@applelink.apple.com (Jim Reekes)
- Date: 9 Oct 92 21:08:46 GMT
- Organization: Apple Computer, Inc.
-
- In article <1992Oct8.171959.6433@genome.wi.edu>, olson@genome.wi.edu (Eric
- K. Olson) wrote:
- >
- > In article <1992Oct6.180458.15224@genome.wi.edu> I (Eric K. Olson) write:
- > >I've been trying to get SPBRecordToFile() to do its thing for me,
- > >on a PowerBook 170, running 7.0.1 + TuneUp 1.1.1, without too much
- > >luck. Here's what I'm doing (schematically):
- > > [...]
- > >When I play back with SndStartFilePlay() I hear that the file
- > >has the sound in it, but with a LOT of very gravelly noise on top of it.
- >
- > Well, I found the answer to this question after a lot of trial and error.
- > It turns out that AIFF files expect the sound data to be in two's-complement
- > format, so one has to turn that on (SetDeviceInfo('twos'...)) in order
- > to record directly to an AIFF file. The gravelly noise is a result of
- > the sign bit being interpreted as a place value of 128.
- >
- > Also, although the 'qual' selector doesn't work with GetDeviceInfo(),
- > it does work with SetDeviceInfo(). You can set it to 'good' ('MAC6' compression),
- > 'betr' ('MAC3' compression), or 'best' ('NONE' compression). Setting the
- > compression directly seems to always return an error.
- >
- > Still don't know why the 'chac' selector fails.
- >
- > So it would seem that you are supposed to set the 'qual' first, then
- > muck with other settings later.
- >
- > NEW QUESTION: Can I use 11 kHz (or lower) sampling rate with 'good'
- > 'qual' ('MAC6' compression)?
-
- Nope. The current MACE assumes a sample rate of 22kHz. Also, don't assume
- that "good" means MACE 3:1. It can be anyone of your sound input driver's
- idea of what good means. To them it may mean a lower sampling rate, a
- different compression (i.e. Farallon 4:1), or a different filtering.
-
- - -----------------------------------------------------------------------
- Jim Reekes, Polterzeitgeist | Macintosh Toolbox Engineering
- | Sound Manager Expert
- Apple Computer, Inc. | RAll opinions expressed are mine, and do
- 20525 Mariani Ave. MS: 81-KS | not necessarily represent those of my
- Cupertino, CA 95014 | employer, Apple Computer Inc.S
-
- ---------------------------
-
- From: resnick@cogsci.uiuc.edu (Pete Resnick)
- Subject: Deferred Tasks - What can I do?
- Organization: University of Illinois at Urbana
- Date: Wed, 7 Oct 1992 00:18:05 GMT
-
- Simple question:
-
- Can I move memory (e.g. call NewPtr) in a deferred task, i.e. one I
- installed with DTInstall?
-
- pr
- - --
- Pete Resnick (...so what is a mojo, and why would one be rising?)
- Graduate assistant - Philosophy Department, Gregory Hall, UIUC
- System manager - Cognitive Science Group, Beckman Institute, UIUC
- Internet: resnick@cogsci.uiuc.edu
-
- +++++++++++++++++++++++++++
-
- From: wuertz@tik.ethz.ch (Andreas Wuertz)
- Date: 7 Oct 92 09:58:30 GMT
- Organization: Federal Institute of Technology
-
- In article <Bvq666.MHH@news.cso.uiuc.edu> Pete Resnick,
- resnick@cogsci.uiuc.edu writes:
- >Simple question:
- >
- >Can I move memory (e.g. call NewPtr) in a deferred task, i.e. one I
- >installed with DTInstall?
-
- Simple question, simple answer: Deferred tasks are defined as tasks that
- are too lengthy to execute as a direct response to an irq, so they're
- deferred to execution with irqs reenabled but just BEFORE returning to
- normal execution; so I'd say you CAN'T make calls to NewPtr a.s.o. But
- this is only MY opinion.
-
- Andy (wuertz@tik.ethz.ch)
-
- ========================================================================
- The only person who got all his work done by Friday was Robinson Crusoe.
- ========================================================================
-
- +++++++++++++++++++++++++++
-
- From: heksterb@cs.utwente.nl (Ben Hekster)
- Date: 7 Oct 92 10:39:50 GMT
- Organization: University of Twente, Dept. of Computer Science
-
- In article <Bvq666.MHH@news.cso.uiuc.edu> resnick@cogsci.uiuc.edu (Pete Resnick) writes:
- >Can I move memory (e.g. call NewPtr) in a deferred task, i.e. one I
- >installed with DTInstall?
-
- I would say, no. The only difference between a VBL and a Deferred Task
- is that a VBL task executes while the processor interrupts are being
- serviced, and a Deferred Task is executed after processor interrupts
- are reenabled. This is so that you don't get a System Error when
- another interrupt arrives while you are still executing a (lengthy)
- task. For all other practical purposes, you are still executing at
- interrupt time-- i.e., the heap may be in an inconsistent state, etc.
-
- - --
- Ben `Hackster' Hekster | "He bides his time and thinks,
- heksterb@cs.utwente.nl | 'There must be more to life than this!'"
-
- +++++++++++++++++++++++++++
-
- From: grobbins@Apple.COM (Grobbins)
- Date: 7 Oct 92 23:59:07 GMT
- Organization: Apple Computer Inc., Cupertino, CA
-
- In article <Bvq666.MHH@news.cso.uiuc.edu> resnick@cogsci.uiuc.edu (Pete Resnick) writes:
- >Can I move memory (e.g. call NewPtr) in a deferred task, i.e. one I
- >installed with DTInstall?
-
- No, since deferred tasks must adhere to interrupt-time restrictions.
- This is discussed in Jim Luther's DTM tech note (#320, for those
- who still believe in numbers.) I'll paste the relevant portion
- below.
-
- Grobbins grobbins@apple.com
-
- Usual disclaimers apply.
-
- - ---
-
- from Tech Note 320, "Deferred Task Traps, Truths, and Tips":
-
- How and when the Deferred Task Manager calls deferred tasks
-
- Since understanding how something works usually answers most questions about
- it, this note gives a complete explanation of how deferred tasks get called.
- I'll start with the occurrence of an interrupt.
-
- When an interrupt occurs, the processor stops executing the current program
- and control is passed to the Macintosh's primary interrupt handler. The
- primary interrupt handler saves registers A0-A3/D0-D3 and then decides what
- secondary interrupt handler to dispatch to. If the system has an MMU, was
- booted 24-bit mode but is presently in 32-bit mode, then the MMU state is
- saved and the MMU is switched to 24-bit mode. If the system has power
- management (i.e., is a portable Macintosh) and is in slow speed, the speed
- is saved and is then switched to full speed. Control is then passed to the
- secondary interrupt handler which handles the interrupt.
-
- When control returns to the primary interrupt handler from the secondary
- interrupt handler, the primary interrupt handler checks to see if there are
- any deferred tasks in the deferred task queue and checks to see if upon exit
- of this interrupt, the processor priority level will be returned to 0. If
- both conditions are true, control is passed to the Deferred Task Manager to
- execute those tasks.
-
- The Deferred Task Manager checks to see if a deferred task is already
- active; if so, the Deferred Task Manager exits. Otherwise, one by one, each
- deferred task in the deferred task queue is dequeued, and then called with
- register A1 containing dtParm from the DeferredTask record and the processor
- priority level is set to 0 (i.e., all interrupts are enabled). When all
- deferred tasks have been dequeued and called, control is returned to the
- primary interrupt handler.
-
- When control returns to primary interrupt handler from the Deferred Task
- Manager, the primary interrupt handler restores the MMU state and speed if
- necessary and then restores registers A0-A3/D0-D3. Then the primary
- interrupt handler returns control to the program executing before the
- interrupt occurred.
-
- With that explanation out of the way, here are a few things that may or may
- not be obvious.
-
- Deferred tasks are interrupt time code
-
- That is, deferred tasks are run as a result of an interrupt. A deferred
- task must follow many of the same rules as a interrupt handler. Here's a
- warning to go along with the material in the Deferred Task Manager chapter
- of Inside Macintosh Volume V.
-
- Warning: Deferred tasks are executed at the interrupt level and must
- preserve all registers other than A0-A3 and D0-D3. Your deferred task must
- not make any calls to the Memory Manager, directly or indirectly, and can't
- depend on handles to unlocked blocks being valid. If it uses application
- globals, it must also ensure that register A5 contains the address of the
- boundary between the application globals and the application parameters; for
- details, see Setting and Restoring the A5 Register in the Memory Management
- chapter of Inside Macintosh Volume VI. Your deferred task should avoid
- accessing a low-memory variables or calling a trap that would access one
- because while MultiFinder@ or System 7 is running, application low-memory
- global variables are being swapped in and out.
-
- Deferred tasks can be interrupted
-
- That's the purpose of using deferred tasks - to let interrupt driven
- processes keep running while your deferred task completes a lengthy task.
- This means that your deferred task must be interruptible-that is, you should
- not have to do anything such as timing-critical hardware access that can get
- screwed up with interrupts on.
-
- If the interrupt handler that installs the deferred task can be called again
- while that deferred task is executing, then you also need to make sure the
- way the interrupt handler and the deferred task code work together is
- reentrant. For example, the interrupt code should not modify a data buffer
- that the deferred task is processing.
-
- Deferred tasks are not prioritized
-
- Deferred tasks are executed in the order they were added to the deferred
- task queue no matter what interrupt level the code installing the task may
- have been running at.
-
- Deferred task latency
-
- There may be significant latency incurred between installing a deferred task
- with DTInstall and when that task is performed. This time is not
- deterministic and cannot be controlled. Real-time response cannot be
- guaranteed on Macintosh computers with or without the use of deferred tasks.
-
- +++++++++++++++++++++++++++
-
- From: REEKES@applelink.apple.com (Jim Reekes)
- Date: 8 Oct 92 19:32:34 GMT
- Organization: Apple Computer, Inc.
-
- In article <1992Oct7.103950.26354@cs.utwente.nl>, heksterb@cs.utwente.nl
- (Ben Hekster) wrote:
- >
- > In article <Bvq666.MHH@news.cso.uiuc.edu> resnick@cogsci.uiuc.edu (Pete Resnick) writes:
- > >Can I move memory (e.g. call NewPtr) in a deferred task, i.e. one I
- > >installed with DTInstall?
- >
- > I would say, no. The only difference between a VBL and a Deferred Task
- > is that a VBL task executes while the processor interrupts are being
- > serviced, and a Deferred Task is executed after processor interrupts
- > are reenabled. This is so that you don't get a System Error when
- > another interrupt arrives while you are still executing a (lengthy)
- > task. For all other practical purposes, you are still executing at
- > interrupt time-- i.e., the heap may be in an inconsistent state, etc.
-
- Both a VBL and a Deferred Task are considered interrupt code. Neither
- can make calls to the toolbox, allocate memory, etc.
-
- VBL tasks are executed with all interrupts enabled. This allows anything
- to interrupt a VBL task. The VBL manager will one run one VBL task at
- any given time, so a VBL cannot interrupt a VBL.
-
- Deferred Tasks are documented in the recent Tech Note, and it explains
- the details of when and how they are executed.
-
- Both a VBL and a Deferred Task are ran with processor interrupts enabled.
-
- - -----------------------------------------------------------------------
- Jim Reekes, Polterzeitgeist | Macintosh Toolbox Engineering
- | Sound Manager Expert
- Apple Computer, Inc. | RAll opinions expressed are mine, and do
- 20525 Mariani Ave. MS: 81-KS | not necessarily represent those of my
- Cupertino, CA 95014 | employer, Apple Computer Inc.S
-
- +++++++++++++++++++++++++++
-
- From: Jeff E Mandel <mandel@tmc.tulane.edu>
- Organization: Tulane University School of Medicine
- Date: Thu, 8 Oct 1992 23:10:12 GMT
-
- In article <REEKES-081092123045@90.10.20.67> Jim Reekes,
- REEKES@applelink.apple.com writes:
- >Both a VBL and a Deferred Task are considered interrupt code. Neither
- >can make calls to the toolbox, allocate memory, etc.
- >
-
- While I understand what you mean, this is not what you are saying. You
- cannot call anything which isn't reentrant, or which presumes that an
- unlocked block is where the handle says it is, etc., but that doesn't
- mean you can't call anything in the toolbox, or even allocate memory.
- There exist techniques whereby you can preallocate a private heap, for
- which you write all of the HeapZone functions, which can be made to
- function within the constraints of interrupt-driven code. Now, most folks
- don't need this, because usually interrupt-driven code does the same
- thing over and over again, and you can get by with just allocating a
- suitably large number of queue elements and managing a free list (like
- the nonpaged dynamic pool, for you VMS folks). You can also do a a
- number of things which lead up to screen output from interrupt-driven
- code, but since it is a major pain to keep track of where things are,
- it's not worth the trouble (I know, I once wrote a preemptive
- dual-tasking executive which allowed me to simulataneously run a
- real-time controller and the user interface, except it bothered the users
- that it would draw graphs through the menus, and they'd subsequently be
- sucked back up into the menubar! (the graphs, not the users)).
-
- Since I probably planted the idea in Pete's head about Deferred Tasks,
- the best thing I can suggest is to decide whether the blocks you need at
- interrupt time can be of a fixed size, or not. If not, you've got to
- write something that manages the memory you preallocate, and probably
- guard the code with a spinlock, as it may get reenterred. Plan on long
- sessions in MacsBug. If it can be of fixed size, then create two OS
- queues, one which contains a list of free blocks, and the other is used
- as your private event queue. It is possible to do this with only one
- queue (this is how the event queue works, but it doesn't permit you as
- much flexibility in priority handling).
-
- Hope this helps,
-
- Jeff E Mandel MD MS
- Associate Professor of Anesthesiology
- Tulane University School of Medicine
- New Orleans, LA
-
- mandel@tmc.tulane.edu
-
- +++++++++++++++++++++++++++
-
- From: resnick@cogsci.uiuc.edu (Pete Resnick)
- Date: 9 Oct 92 16:25:11 GMT
- Organization: University of Illinois at Urbana
-
- Jeff E Mandel <mandel@tmc.tulane.edu> writes:
-
- >Since I probably planted the idea in Pete's head about Deferred Tasks,
-
- You did. :-)
-
- >the best thing I can suggest is to decide whether the blocks you need at
- >interrupt time can be of a fixed size, or not.
-
- They are fixed size in my case, and I will probably implement this
- using an private queue. The problem was that I didn't want to
- pre-allocate all of this memory since many of the blocks may never be
- used, but it shouldn't be too big a deal.
-
- Thanks to everyone for the input.
-
- pr
- - --
- Pete Resnick (...so what is a mojo, and why would one be rising?)
- Graduate assistant - Philosophy Department, Gregory Hall, UIUC
- System manager - Cognitive Science Group, Beckman Institute, UIUC
- Internet: resnick@cogsci.uiuc.edu
-
- +++++++++++++++++++++++++++
-
- From: REEKES@applelink.apple.com (Jim Reekes)
- Date: 9 Oct 92 21:05:30 GMT
- Organization: Apple Computer, Inc.
-
- In article <1992Oct8.231012.1588@cs.tulane.edu>, mandel@tmc.tulane.edu
- (Jeff E Mandel) wrote:
- >
- > In article <REEKES-081092123045@90.10.20.67> Jim Reekes,
- > REEKES@applelink.apple.com writes:
- > >Both a VBL and a Deferred Task are considered interrupt code. Neither
- > >can make calls to the toolbox, allocate memory, etc.
- > >
- >
- > While I understand what you mean, this is not what you are saying. You
- > cannot call anything which isn't reentrant, or which presumes that an
- > unlocked block is where the handle says it is, etc., but that doesn't
- > mean you can't call anything in the toolbox, or even allocate memory.
- > There exist techniques whereby you can preallocate a private heap, for
- > which you write all of the HeapZone functions, which can be made to
- > function within the constraints of interrupt-driven code. Now, most folks
- > don't need this, because usually interrupt-driven code does the same
- > thing over and over again, and you can get by with just allocating a
- > suitably large number of queue elements and managing a free list (like
- > the nonpaged dynamic pool, for you VMS folks). You can also do a a
- > number of things which lead up to screen output from interrupt-driven
- > code, but since it is a major pain to keep track of where things are,
- > it's not worth the trouble (I know, I once wrote a preemptive
- > dual-tasking executive which allowed me to simulataneously run a
- > real-time controller and the user interface, except it bothered the users
- > that it would draw graphs through the menus, and they'd subsequently be
- > sucked back up into the menubar! (the graphs, not the users)).
- >
- > Since I probably planted the idea in Pete's head about Deferred Tasks,
- > the best thing I can suggest is to decide whether the blocks you need at
- > interrupt time can be of a fixed size, or not. If not, you've got to
- > write something that manages the memory you preallocate, and probably
- > guard the code with a spinlock, as it may get reenterred. Plan on long
- > sessions in MacsBug. If it can be of fixed size, then create two OS
- > queues, one which contains a list of free blocks, and the other is used
- > as your private event queue. It is possible to do this with only one
- > queue (this is how the event queue works, but it doesn't permit you as
- > much flexibility in priority handling).
-
- While you think you know what I mean, you really don't. I was avoiding
- a long discussion about all the hows and whys. It's much more truthful to
- state that you cannot call any toolbox calls. There are few that can be,
- and Apple doesn't document them because we couldn't. The list of
- exceptions
- is far too great. Besides, the movement is to avoid interrupt code
- entirely.
-
- Here's a little more data about the issue. Not only is allocating
- or moving blocks in the heap illegal during interrupt, you cannot call
- routines that are non-reentrant. This just about excludes all of the
- toolbox. The Mac toolbox uses lots of low memory globals, much more than
- that Inside Mac ever talks about. Because of this global state
- information,
- you cannot call a routine that depends on such a globals.
-
- Furthermore, some of these globals are swapped during a tasks context.
- For
- example, FrontWindow refers to the global WindowList. This global is
- swapped for
- the current process. Even thou FrontWindow doesn't move or allocate
- memory,
- nor does it have a reentrancy problem, but it cannot be called a interrupt
- level.
-
- Because of this last issue, things get really sticky. We don't have a list
- of which globals are swapped for a task, and it changes for the many
- releases
- of the MultiFinder/Process Manager. This is part of the reason we cannot
- document entirely which calls cannot be called at interrupt level. We do
- attempt to provide a list of the ones we promise to be safe, such as
- StripAddress.
-
- - -----------------------------------------------------------------------
- Jim Reekes, Polterzeitgeist | Macintosh Toolbox Engineering
- | Sound Manager Expert
- Apple Computer, Inc. | RAll opinions expressed are mine, and do
- 20525 Mariani Ave. MS: 81-KS | not necessarily represent those of my
- Cupertino, CA 95014 | employer, Apple Computer Inc.S
-
- ---------------------------
-
- From: udmorrow@mcs.drexel.edu (Daniel Morrow)
- Subject: problem with my dialog filter
- Date: 7 Oct 92 16:48:27 GMT
- Organization: Drexel University
-
- Basically, all I'm doing is checking an edit text field in my
- dialog to see if there is anything in it. If not I dim out the
- OK button, if so, the OK button becomes active again.
-
- Anyway, this part works. The part that doesn't work is checking
- for carriage returns when the OK button is enabled.
-
- I do the following in my filter now:
- Set itemHit to the id of the OK button
- Set event.what to mouseDown.
- Set event.where to a point inside the OK button
- and I do call LocalToGlobal on that point.
- And lastly I set MyFilter to FALSE so ModalDialog knows
- to handle the event.
-
- Am I missing something here?
-
- Please help.
-
- Thanks.
- - -Dan.
- udmorrow@mcs.drexel.edu
-
- +++++++++++++++++++++++++++
-
- From: Ted Lowery <tbl@rock.concert.net>
- Organization: MacSolutions
- Date: Thu, 8 Oct 1992 16:46:57 GMT
-
- Try this...
-
- void FlashButton(int ButtonID);
- /* just flash the button, visual only */
- void FlashButton(int ButtonID)
- {
- Rect itemRect;
- long ticksLater;
-
- itemRect = GetDRect (ButtonID);
- InsetRect (&itemRect, 1, 1);
- InvertRoundRect (&itemRect, 8, 8);
- ticksLater = TickCount() + 10; /* wait a sixth second...I don't know */
- while (TickCount() < ticksLater) ; /* if that is standard, I just
- guessed */
- InvertRoundRect (&itemRect, 8, 8);
- }
-
-
-
- pascal Boolean charFilter(DialogPtr theDialog,EventRecord *theEvent,short
- *itemHit);
- pascal Boolean charFilter(DialogPtr theDialog,EventRecord *theEvent,short
- *itemHit)
- {
- Str255 theText;
- if (theEvent->what != keyDown) return(FALSE); /* only looking for key
- downs */
-
- switch ((theEvent->message) & charCodeMask) {
- case 0x0D:
- case 0x03:
- *itemHit = OKButton; /* basically tell ModalDialog we handled the
- */
- FlashButton(OKButton); /* keydown, but now there is an itemHit that
- */
- return(TRUE); /* than ModalDialog gets to handle */
- break;
-
- default:
- break;
- }
- }
-
- Hope this helps.
-
- Ted
- tbl@rock.concert.net
-
- +++++++++++++++++++++++++++
-
- From: mxmora@unix.SRI.COM (Matt Mora)
- Date: 9 Oct 92 00:28:01 GMT
- Organization: SRI International, Menlo Park, California
-
- In article <D88-JWA.92Oct8205414@byse.nada.kth.se> d88-jwa@byse.nada.kth.se (Jon Wtte) writes:
-
- >You should use _Delay, which is a system call that does just
- >this, but also calls SystemTask. It might also do other
- >things in the future. Doing only this is really bad, since
- >there may be drivers that need time often.
-
- I would hate to disagree with Jon but I don't think delay calls systemtask.
- I think it just stuffs LMG "ticks" into d0 , adds the delay amount and loops
- until "ticks" is bigger than d0.
-
- I created my own Delay function that calls WNE with the sleep at 1 tick. It
- works ok.
-
-
- Matt
-
-
-
-
-
-
-
- - --
- ___________________________________________________________
- Matthew Mora | my Mac Matt_Mora@sri.com
- SRI International | my unix mxmora@unix.sri.com
- ___________________________________________________________
-
- +++++++++++++++++++++++++++
-
- Date: 9 Oct 92 09:05:55 GMT
- Organization: Royal Institute of Technology, Stockholm, Sweden
-
- In article <39359@unix.SRI.COM> mxmora@unix.SRI.COM (Matt Mora) writes:
-
- >You should use _Delay, which is a system call that does just
- >this, but also calls SystemTask. It might also do other
- >things in the future. Doing only this is really bad, since
- >there may be drivers that need time often.
-
- I would hate to disagree with Jon but I don't think delay calls systemtask.
- I think it just stuffs LMG "ticks" into d0 , adds the delay amount and loops
- until "ticks" is bigger than d0.
-
- Okay, but the "might do other things in the future" still
- holds :-) (Actually, it also sets the status register;
- interrupt level one might think)
-
- I created my own Delay function that calls WNE with the sleep at 1 tick. It
- works ok.
-
- As long as you don4t get update, or suspend, or ... events
- while in the delay loop. At least you can mask those out;
- AppleEvents, however, can NEVER be masked out, so you had
- better be prepared handle them whenever you call WaitNextEvent.
-
- - --
- Jon W{tte, h+@nada.kth.se, Sweden, Phone +46-8-107069
-
- "From now on, I think I'll re-label the EQ on the
- desk as Fizz and Wobble, rather than HF and LF."
-
- +++++++++++++++++++++++++++
-
- From: wuertz@tik.ethz.ch (Andreas Wuertz)
- Date: 9 Oct 92 13:34:30 GMT
- Organization: Federal Institute of Technology
-
- In article <1992Oct7.164827.26670@mcs.drexel.edu> Daniel Morrow,
- udmorrow@mcs.drexel.edu writes:
- > Set itemHit to the id of the OK button
- > Set event.what to mouseDown.
- > Set event.where to a point inside the OK button
- > and I do call LocalToGlobal on that point.
- > And lastly I set MyFilter to FALSE so ModalDialog knows
- > to handle the event.
-
- How about setting MyFilter to TRUE, so ModalDialog knows YOU handled the
- event and doesn't fiddle around with itemHit anymore?
-
- In article <1992Oct8.164657.26841@nrtpa038.bnr.ca> Ted Lowery,
- tbl@rock.concert.net writes:
- >void FlashButton(int ButtonID);
- >/* just flash the button, visual only */
- >void FlashButton(int ButtonID)
- >{
- > Rect itemRect;
- > long ticksLater;
- >
- > itemRect = GetDRect (ButtonID);
- > InsetRect (&itemRect, 1, 1);
- > InvertRoundRect (&itemRect, 8, 8);
- > ticksLater = TickCount() + 10; /* wait a sixth second...I don't know
- */
- > while (TickCount() < ticksLater) ; /* if that is standard, I just
- >guessed */
- > InvertRoundRect (&itemRect, 8, 8);
- >}
-
- I don't believe this! How about this one:
- void FlashButton(DialogPtr theDialog, int buttonID)
- /* This will also work in System 9.5 (known as 'Violett') where buttons
- become dark red with greenish dots when the are clicked */
- {
- GetDItem(theDialog, buttonID, &itemType, &itemHandle, itemBox);
- HiliteControl(itemHandle, 1);
- Delay(10);
- HiliteControl(itemHandle, 0); /* that's it! */
- }
-
- By the way:
- Delay causes the system to wait for the number of ticks (sixtieths of a
- second)
- specified by numTicks, and returns in finalTicks the total number of
- ticks from
- system startup to the end of the delay.
-
- Warning: Don't rely on the duration of the delay being exact; it will
- usually
- be accurate to within one tick, but may be off by more than
- that.
- The Delay procedure enables all interrupts and checks the tick
- count
- that's incremented during the vertical retrace interrupt;
- however,
- it's possible for this interrupt to be disabled by other
- interrupts,
- in which case the duration of the delay will not be exactly
- what you
- requested.
-
- Assembly-language note:??On exit from this procedure, register D0
- contains the
- value of the global variable Ticks as measured
- at the
- end of the delay.
-
- Andy (wuertz@tik.ethz.ch)
-
- ========================================================================
- The only person who got all his work done by Friday was Robinson Crusoe.
- ========================================================================
-
- ---------------------------
-
- From: yjc@po.cwru.edu (Jerome Chan)
- Subject: Apple Events! How to locate a service?
- Date: 7 Oct 92 19:33:16 GMT
- Organization: The Tofu Society of Singapore
-
-
- Apple Events is a cool way to communicate between various applications.
- However, I noticed a drawback. It doesn't have a services directory.
- Everytime there is a need to locate a particular application
- service/server, I've got to fiddle around with the PPC thingies. If the
- application/server providing the service is not running, there is no way my
- application can find out where the server/application is located, launch it
- and continue (with the user's consent of course!).
-
- A services directory (sd) would be a nice thing to have. An application
- would register with the sd, indicating if it provides local and/or global
- services. The sd would then inform all other sd's on the AppleTalk net of
- this new addition if global services are provided. When an application
- requires to connect to a particulat service, it would query the sd to find
- the correct address. The sd could also keep a record of previously active
- services and their locations and launch them (via AEs to the
- approperiate(spelling?) finder) if requested
-
- Is there something else available/comming soon that would provide this
- functionality? Are the software people at Apple going to provide something
- like this in the next system release? Anyone know? Am I wasting my time?
-
- Maybe it's because it's four o'clock in the afternoon.
-
-
-
- - ---
- The Evil Tofu
-
- +++++++++++++++++++++++++++
-
- From: ross@bnr.ca (Ross Brown)
- Date: 8 Oct 92 15:56:41 GMT
- Organization: Bell-Northern Research Ltd.
-
- In article <yjc-071092151355@b61539.student.cwru.edu> yjc@po.cwru.edu (Jerome
- Chan) writes:
- >
- > Apple Events is a cool way to communicate between various applications.
- >However, I noticed a drawback. It doesn't have a services directory.
- >Everytime there is a need to locate a particular application
- >service/server, I've got to fiddle around with the PPC thingies. If the
- >application/server providing the service is not running, there is no way my
- >application can find out where the server/application is located, launch it
- >and continue (with the user's consent of course!).
-
- Well, there's no sure-fire programmatic way of doing it in System 7, but if
- your local program knows that the remote application/server has a certain PPC
- port name, or a certain NBP entity type alias assigned by PPC, and your machine
- has an alias to the application/server somewhere on its disk, then everything
- you describe can be done by a program on your machine without alerting the
- user, with the requisite combination of IPCListPorts, StartSecureSession, and
- remote Finder AEs. This amounts to implementing a services directory on the
- *client* machine rather than the *server*, which may not be what you want, but
- it works.
-
- A directory server capability of the sort you describe could be built into the
- client program on the standard of signatures. PPC allows servers to register
- themselves on the network on a creator/type basis, so client programs can use
- signatures to check whether a server is running. The desktop database has a
- call (PBDTGetAPPL) which can find the location of the server program given its
- signature. Once your client program mounts the remote volume where the server
- program lives, you can use PBDTGetAPPL with ioVRefNum referring to the remote
- volume. The resulting value in ioAPPLParID gives you the exact directory,
- which you can easily search to find the server program. Make an alias, send a
- 'sope' AE to the remote Finder, and voila.
-
- I'd like to see the result, once you get it working!
-
- ==============================================================================
- Ross Brown, Dept. 7C22 < Bell-Northern Research > Just the facts, ma'am.
- Advisor, Telemgmt Svcs < P. O. Box 3511, Station C > We don't care whose
- ross@bnr.ca < Ottawa, ON, Canada K1Y 4H7 > opinions yours aren't.
- ==============================================================================
-
- +++++++++++++++++++++++++++
-
- From: cshotton@oac.hsc.uth.tmc.edu (Chuck Shotton)
- Date: 8 Oct 1992 21:00:25 GMT
- Organization: Academic Computing
-
- In article <D88-JWA.92Oct8204556@byse.nada.kth.se>,
- d88-jwa@byse.nada.kth.se (Jon Wtte) wrote:
- >
- > And still we don't have a good service dictionary in the system.
- > Anyone care to try and position the HLE and the AE in the OSI
- > stack? PPC should be at the same level as TCP, i.e. level 3 ?
- > (starting at 0)
- >
-
- AE.... Session level.
-
- - --_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
- Chuck Shotton |
- Ass't Director, Academic Computing | "This space for rent."
- UT Health Science Center Houston |
- cshotton@oac.hsc.uth.tmc.edu |
- _-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
-
- +++++++++++++++++++++++++++
-
- Organization: Royal Institute of Technology, Stockholm, Sweden
- Date: Thu, 8 Oct 1992 19:45:56 GMT
-
- > ross@bnr.ca (Ross Brown) writes:
-
- > Well, there's no sure-fire programmatic way of doing it in System 7,
- > but if your local program knows that the remote application/server has
- > a certain PPC port name, or a certain NBP entity type alias assigned
-
- Well, everything would be nicer if you could actually USE the
- documented-but-not-implemented type/creator port format. Now
- you can use the not-documented-but-I-hope-stable format <creator>ep01
- (ep == Event Port ?)
-
- > somewhere on its disk, then everything you describe can be done by a
- > program on your machine without alerting the user, with the requisite
- > combination of IPCListPorts, StartSecureSession, and remote Finder
-
- Nope; you still have to use program linking to establish an
- AppleEvent channel (username & password) - We work around that
- using AutoGuest INIT, but that's REALLY skanky (we should, at
- least, use the library version)
-
- Does the finder listen to remote events? I thought not. Therefore
- you have to write a small system extension (background application)
- that listens for specific AppleEvents and relays them to the local
- finder. Talk about security hole :-)
-
- According to Really Heavy Names (i.e. the guys who did it) this
- is not easily solvable, since the AE manager lies on top of the
- HLE manager, which lies on top of PPC. If AE lied directly on
- top of PPC, one could conceive of specific attributes for name
- and password; however, the HLE manager known nothing about what
- you send through it.
-
- And still we don't have a good service dictionary in the system.
- Anyone care to try and position the HLE and the AE in the OSI
- stack? PPC should be at the same level as TCP, i.e. level 3 ?
- (starting at 0)
-
- Cheers,
-
- / h+
-
- - --
- Jon W{tte, h+@nada.kth.se, Sweden, Phone +46-8-107069
-
- "From now on, I think I'll re-label the EQ on the
- desk as Fizz and Wobble, rather than HF and LF."
-
- +++++++++++++++++++++++++++
-
- From: ross@bnr.ca (Ross Brown)
- Organization: Bell-Northern Research Ltd.
- Date: Fri, 9 Oct 92 20:33:08 GMT
-
- In article <D88-JWA.92Oct8204556@byse.nada.kth.se> d88-jwa@byse.nada.kth.se
- (Jon Wtte) writes:
- >[stuff deleted]
- >Does the finder listen to remote events? I thought not. Therefore
- >you have to write a small system extension (background application)
- >that listens for specific AppleEvents and relays them to the local
- >finder. Talk about security hole :-)
-
- Does Finder listen to remote events? It does for me. Check out Jon Pugh's
- FinderEvents stack. In the description of the Open Selection and Print
- Selection events, he mentions that these are the only ones you can fire at a
- remote Finder, and by Jove, it works.
-
- You may have noticed that Finder always appears in the list of programs when
- you are poking around the network in the PPC Browser. In fact, there's no
- Sharing dialog for Finder, so you can't tell it *not* to listen to remote
- events... 'sope' and 'spri', at least.
-
- ==============================================================================
- Ross Brown, Dept. 7C22 < Bell-Northern Research > Just the facts, ma'am.
- Advisor, Telemgmt Svcs < P. O. Box 3511, Station C > We don't care whose
- ross@bnr.ca < Ottawa, ON, Canada K1Y 4H7 > opinions yours aren't.
- ==============================================================================
-
-
- ---------------------------
-
- End of C.S.M.P. Digest
- **********************
-